﻿Imports System.Data.SqlClient
Public Class frmCargosNuevos
    Dim existenCargos As Boolean
    Dim Bitacora As New clsActividad
    Private Sub frmCargosNuevos_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.CheckBox1.Checked = False

        Me.dgCargos.Rows.Clear()
        existenCargos = False

        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim cmdBuscar As New SqlCommand
        cmdBuscar.Connection = cnConn
        cmdBuscar.CommandText = "SELECT tipo,cobro,destino,usuario,nombrecompleto From Accidentes A INNER JOIN Empleados E " & _
        " ON A.idempleado=E.idempleado WHERE reportado='No' order by TIPO,DESTINO,NOMBRECOMPLETO"

        Dim rdBuscar As SqlDataReader

        cnConn.Open()
        rdBuscar = cmdBuscar.ExecuteReader

        Do While rdBuscar.Read()
            existenCargos = True
            Me.dgCargos.Rows.Add(rdBuscar("NombreCompleto"), rdBuscar("tipo"), rdBuscar("cobro"), rdBuscar("destino"), rdBuscar("usuario"))
        Loop

        If existenCargos = False Then
            Me.Close()

        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub RadButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadButton2.Click
        If Me.CheckBox1.Checked = True Then
            Call SetSqlCitra("Update Accidentes set reportado='Si' where reportado='No'")
            'Registra actividad
            Bitacora.RegistraActividad("Revisó las notificaciones de cargos nuevos")
            Me.Close()
        Else
            Me.Close()
        End If
    End Sub

    Private Sub btnAbrir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAbrir.Click
        ToExcel(Me.dgCargos, "Relacion de nuevos cargos al " & Now())
    End Sub
End Class